package com.example.common.exception;

import com.example.common.constants.MSG_ALERT_ENUM;
import com.example.common.dto.TransResult;
import lombok.Data;

/**
 * @author ：czx
 * @date ：Created in 2021/6/24 15:14
 * @modified By：
 */
@Data
public class BusinessException extends RuntimeException{
    /**
     *  业务异常返回对象
     */
    private TransResult transResult;


    /**
     *  异常内容封装
     * @param msgAlertEnum
     */
    public BusinessException(MSG_ALERT_ENUM msgAlertEnum){
        super(msgAlertEnum.getMessage());
        transResult = new TransResult();
        transResult.setResultCode(msgAlertEnum.getCode());
        transResult.setResultInfoDesc(msgAlertEnum.getMessage());
    }
    /**
     *  异常内容封装
     * @param msg
     */
    public BusinessException(String msg){
        super(msg);
        transResult = new TransResult();
        transResult.setResultInfoDesc(msg);
    }
    /**
     *  异常内容封装
     * @param code
     * @param msg
     */
    public BusinessException(String code,String msg){
        super(msg);
        transResult = new TransResult();
        transResult.setResultCode(code);
        transResult.setResultInfoDesc(msg);
    }
}
